home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / obero / oberon_lib.lha / oberon-a / source1.lha / source / amigautil / ClassFace.asm < prev   
Assembly Source File  |  1994-08-08  |  4KB  |  113 lines

  1. *  Classface.asm - Intuition object/class method invocation
  2. *  This is the Version for non-C language wich didn't use
  3. *  the stupid C paramater stack :), it uses Register
  4. *
  5. *  Classface.asm is Copyright (C) Albert Weinert.
  6. *  Freely distributable under the GNU Library General Public Licence.
  7. *
  8. *  Minor modifications by Frank Copeland [fjc].
  9. *
  10. * Code in here "freezes" these facts (and no others):
  11. *       - pointer to an object's class immediately precedes the object pointer
  12. *       - pointer to a class's superclass is (h_SIZEOF+4) into the class
  13.  
  14.         TTL ClassFace                  ; Added to assemble with PhxAss [fjc]
  15.  
  16.         INCLUDE 'exec/types.i'
  17.         INCLUDE 'exec/nodes.i'
  18.  
  19.         INCLUDE 'utility/hooks.i'
  20.         INCLUDE 'intuition/classusr.i'
  21.  
  22. * varargs interfaces for invoking method functions
  23.         xdef    _a_DoMethodA
  24.         xdef    _a_DoSuperMethodA
  25.         xdef    _a_CoerceMethodA
  26.         xdef    _a_SetSuperAttrs
  27.  
  28.         SECTION ClassFace,CODE         ; Added to assemble with PhxAss [fjc]
  29.  
  30. * DoMethod( o, method_id, param1, param2, ... )
  31. * Invoke upon an object the method function defined by an object's class.
  32. * This function is the only one that you should use unless you are
  33. * implementing a class.
  34. *
  35. _a_DoMethodA: ;( a2 : Object; a1 : Msg );
  36.         move.l  a2,-(a7)        ; rely on a6 being preserved
  37.         move.l  a2,d0           ; be safe
  38.         beq.s   cmnullreturn
  39.         move.l  -4(a2),a0       ; object class ptr precedes object
  40.  
  41.         bra.s   cminvoke        ; will cleanup a2
  42.         ; ----- don't return here
  43.  
  44. * DoSuperMethod( cl, o, method_id, param1, param2, ... )
  45. * Invoke upon an object the method defined for the superclass
  46. * of the class specified.  In a class implementation, you
  47. * are passed a pointer to the class you are implementing, which
  48. * you pass to this function to send a message to the object
  49. * considered as a member of your superclass.
  50. *
  51. _a_DoSuperMethodA: ;( a0 : Class; a2 : Object; a1 : Msg );
  52.         move.l  a2,-(a7)        ; rely on a6 being preserved
  53.         move.l  a2,d0           ; be safe (object)
  54.         beq.s   cmnullreturn
  55.         move.l  a0,d0           ; be safe (class)
  56.         beq.s   cmnullreturn
  57.         move.l  h_SIZEOF+4(a0),a0       ; substitute superclass
  58.  
  59.         bra.s   cminvoke        ; will cleanup a2
  60.         ; ----- don't return here
  61.  
  62. * CoerceMethod( cl, o, method_id, param1, param2, ... );
  63. * Invoke upon the given object a method function for whatever
  64. * specified class.  This is sort of the primitive basis behind
  65. * DoMethod and DoSuperMethod.
  66. *
  67. _a_CoerceMethodA: ;( a0 : Class; a2 : Object; a1 : Msg );
  68.         move.l  a2,-(a7)        ; rely on a6 being preserved
  69.         move.l  a2,d0           ; be safe (object)
  70.         beq.s   cmnullreturn
  71.         move.l  a0,d0           ; be safe (class)
  72.         beq.s   cmnullreturn
  73.         ; --- registers ready, now call hook
  74.         ;bra.s   cminvoke
  75.         ; ----- don't return here
  76.  
  77.  
  78. cminvoke:
  79.         pea.l   cmreturn(pc)
  80.         move.l  h_Entry(a0),-(sp)
  81.         rts
  82. cmnullreturn:
  83.         moveq.l #0,d0
  84. cmreturn:
  85.         move.l  (sp)+,a2
  86.         rts
  87.  
  88.  
  89.  
  90. * SetSuperAttrs( cl, o, tag1, data1, ..., TAG_END );
  91. * A useful varargs conversion to the proper OM_SET method.
  92. _a_SetSuperAttrs: ;( a0 : Class; a2 : Object; a1 : Msg );
  93.         move.l  a2,-(a7)        ; save
  94.         move.l  a2,d0           ; be safe (object)
  95.         beq.s   cmnullreturn
  96.         move.l  a0,d0           ; be safe (class)
  97.         beq.s   cmnullreturn
  98.  
  99.         move.l  h_SIZEOF+4(a0),a0       ; substitute superclass
  100.         move.l   #0,-(SP)
  101.         move.l   a1,-(SP)
  102.         move.l  #OM_SET,-(SP)        ; MethodID OM_SET
  103.         move.l  SP,A1
  104.         pea.l   ssaret(pc)
  105.         move.l  h_Entry(a0),-(sp)
  106.         rts
  107. ssaret:
  108.         lea     12(sp),sp
  109.         move.l  (sp)+,a2
  110.         rts
  111.  
  112.         end
  113.